package com.goods.business.converter;

import com.goods.common.model.business.InStock;
import com.goods.common.vo.business.InStockVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class InStockConverter {

    /**
     * 转vo
     */
    public static InStockVO converterToInStockVO(InStock inStock){
        InStockVO inStockVO = new InStockVO();
        BeanUtils.copyProperties(inStock,inStockVO);
        return inStockVO;
    }

    /**
     * 转成inStockVOList
     */
    public static List<InStockVO> converterToInStockVOList(List<InStock> inStockList){
        List<InStockVO> inStockVOList = new ArrayList<>();
        if(!CollectionUtils.isEmpty(inStockList)){
            for (InStock inStock : inStockList) {
                InStockVO inStockVO = converterToInStockVO(inStock);
                inStockVOList.add(inStockVO);
            }
        }
        return inStockVOList;
    }
}
